package com.arong.swing.db.entity;

public class PagingInfo {
    // 每页行数
    private int pageRows = 10;

    // 当前页码
    private int pageNum = 1;

    // 分页查询起始编号
    private int startIdx;

    // 分页查询结束编号
    private int endIdx;

    // 查询结果的总条数
    private long totalRows;

    // 查询结果的总页数
    private int totalPages;

    public int getPageRows() {
        return pageRows;
    }

    public void setPageRows(int pageRows) {
        this.pageRows = pageRows;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getStartIdx() {
        startIdx = pageRows * (pageNum - 1) + 1;
        return startIdx;
    }

    public int getEndIdx() {
        endIdx = startIdx + pageRows - 1;
        return endIdx;
    }

    public long getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(long totalRows) {
        this.totalRows = totalRows;
    }

    public int getTotalPages() {
        totalPages = (int)((totalRows + pageRows - 1) / pageRows);
        return totalPages;
    }

    public void setStartIdx(int startIdx) {
        this.startIdx = startIdx;
    }

    public void setEndIdx(int endIdx) {
        this.endIdx = endIdx;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }
}
